class Pay {
    constructor(bank_card_no: string, balance: number, cost: number,tokenid: string){
        this.bank_card_no = bank_card_no
        this.balance = balance
        this.cost = cost
        this.tokenid = tokenid
    }
    // 支付父类
    bank_card_no: string
    balance: number
    cost: number
    tokenid: string
    pay(){
        console.log('支付银行卡卡号:',this.bank_card_no );
        
    }
}

enum PayType {
    WebChat = 1,
    AliPay = 2,
    CloudFlashPayment = 3
}

// 银行卡支付
class BankPay extends Pay {
    bank_newwork!: string
    bankno_type!: number
    bank_card_psw!: string
    custname!: string
}

class MobilePay extends Pay {
    constructor(
        bank_card_no: string,
        balance: number,
        cost: number,
        tokenid: string,
        type: PayType,
        change: number,
        openid: string,
        appid: string
    ) {
        super(bank_card_no,balance,cost,tokenid)
        this.type = type
        this.change = change
        this.opendid = openid
        this.appid = appid
    }

    type: PayType
    change: number
    opendid: string
    appid: string

    pay(){
        super.pay()
        console.log("完成支付");
        
    }
}



class Customer {
    pay(payMethod: BankPay | MobilePay){
        // payMethod.  提示她俩共有的属性 BankPay | MobilePay

        // if("appid" in payMethod){
        //     // payMethod.   ---提示 MobilePay
        // }
        if(payMethod instanceof MobilePay){
            // payMethod.
            // payMethod.  提示 MobilePay 的属性
        }else if(payMethod instanceof BankPay){
            // payMethod.  提示 BankPay 的属性
        }
    }
}

let WebChatPay = new MobilePay('1111',300,1000,'123',PayType.WebChat,10,'147','4568')
console.log(WebChatPay);
WebChatPay.pay()

let cust = new Customer()
cust.pay(WebChatPay)


// typeof的使用
function call(num:string|number){
    // num.  --string类型的方法
    if(typeof num ==='number'){
        //num.   --number类型的方法
    }
}










export {}